import Vue from 'vue'
import Main from '../views/Main.vue'

const home = r =>require.ensure([],()=>r(require('../views/home/home.vue')),'home')
const list = r =>require.ensure([],()=>r(require('../views/shop/list.vue')),'list')
const login = r =>require.ensure([],()=>r(require('../views/login.vue')),'login')


export const routes = [
  {
    path: '',
    component: Main,
    meta: {
      requireAuth: true,
    },
    children:[
      {
        path:'',
        redirect:'/home'
      },
      {
        path:'/home',
        name: 'home_index',
        component:home
      },
      {
        path:'/list',
        component:list
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: 'Login - 登录'
    },
    component: login
  }
]
export const appRouter = [
  {
    path: '/access',
    redirect: '/access/index',
    icon: 'key',
    name: 'access',
    title: '权限管理',
    meta: {
      requireAuth: true,
    },
    component: Main,
    children: [
      { path: 'index', title: '权限管理', name: 'access_index', component: list }
    ]
  },
  {
    path: '/access-test',
    icon: 'lock-combination',
    title: '权限测试页',
    name: 'accesstest',
    access: 0,
    meta: {
      requireAuth: true,
    },
    component: Main,
    children: [
      { path: 'index', title: '权限测试页', name: 'accesstest_index',component:list }
    ]
  },
  {
    path: '/component',
    icon: 'social-buffer',
    name: 'component',
    title: '组件',
    component: Main,
    meta: {
      requireAuth: true,
    },
    children: [
      {
        path: 'text-editer',
        icon: 'compose',
        name: 'text-editer',
        title: '富文本编辑器',
        component: list
      },
      {
        path: 'md-editor',
        icon: 'pound',
        name: 'md-editor',
        title: 'Markdown编辑器',
        component: list
      },
      {
        path: 'draggable-list',
        icon: 'arrow-move',
        name: 'draggable-list',
        title: '可拖拽列表',
        component: list
      },
      {
        path: 'file-upload',
        icon: 'android-upload',
        name: 'file-upload',
        title: '文件上传',
        component: list
      },
      {
        path: 'count-to',
        icon: 'arrow-graph-up-right',
        name: 'count-to',
        title: '数字渐变',
        component: list
      }
    ]
  },
  {
    path: '/form',
    icon: 'android-checkbox',
    name: 'form',
    title: '表单编辑',
    component: Main,
    meta: {
      requireAuth: true,
    },
    children: [
      { path: 'artical-publish', title: '文章发布', name: 'articalpublish', icon: 'compose', component: list },
      { path: 'workflow', title: '工作流', name: 'workflow', icon: 'arrow-swap', component: list }

    ]
  },
  {
    path: '/tables',
    icon: 'ios-grid-view',
    name: 'tables',
    title: '表格',
    component: Main,
    meta: {
      requireAuth: true,
    },
    children: [
      { path: 'dragableTable', title: '可拖拽排序', name: 'dragableTable', icon: 'arrow-move', component: list },
      { path: 'editableTable', title: '可编辑表格', name: 'editableTable', icon: 'edit', component:list },
      { path: 'exportableTable', title: '表格导出数据', name: 'exportableTable', icon: 'code-download', component: list },
      { path: 'table2image', title: '表格转图片', name: 'table2image', icon: 'images', component: list }
    ]
  },
  {
    path: '/error-page',
    icon: 'android-sad',
    title: '错误页面',
    name: 'errorpage',
    component: Main,
    meta: {
      requireAuth: true,
    },
    children: [
      { path: 'index', title: '错误页面', name: 'errorpage_index', component: list }
    ]
  }
];

export const R = [
  ...routes,
  ...appRouter
]
